Handle nested schema namespaces#3445
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesJsonSchemaParser ref and namespace definition fixes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
📚 Docs Preview: https://pr-3445.datamodel-code-generator.pages.dev |
Merging this PR will improve performance by 16.07%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | WallTime | test_perf_large_models_pydantic_v2 |
3.8 s | 3.2 s | +18.48% |
| ⚡ | WallTime | test_perf_all_options_enabled |
5.6 s | 4.7 s | +18.19% |
| ⚡ | WallTime | test_perf_openapi_large |
3 s | 2.6 s | +17.87% |
| ⚡ | WallTime | test_perf_duplicate_names |
1,131.7 ms | 969.4 ms | +16.74% |
| ⚡ | WallTime | test_perf_deep_nested |
5.4 s | 4.6 s | +16.69% |
| ⚡ | WallTime | test_perf_multiple_files_input |
3.7 s | 3.2 s | +16.08% |
| ⚡ | WallTime | test_perf_complex_refs |
2.1 s | 1.8 s | +16.01% |
| ⚡ | WallTime | test_perf_kubernetes_style_pydantic_v2 |
2.7 s | 2.3 s | +15.48% |
| ⚡ | WallTime | test_perf_graphql_style_pydantic_v2 |
819.1 ms | 712.3 ms | +15% |
| ⚡ | WallTime | test_perf_aws_style_openapi_pydantic_v2 |
1.9 s | 1.7 s | +14.32% |
| ⚡ | WallTime | test_perf_stripe_style_pydantic_v2 |
2 s | 1.8 s | +12.1% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing schema-shape-resolution (54e351f) with main (61e08d4)
Footnotes
-
98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/datamodel_code_generator/parser/jsonschema.py`:
- Around line 5303-5305: The _is_current_root_schema_path method currently
compares path directly against current_root or ["#"] in strict equality, but
this misses equivalent root path representations used elsewhere in the file such
as path_parts concatenated with ["#"] and resolved file# references. Normalize
both the path parameter and the current_root list to a canonical form before
comparison so that all equivalent root path representations are recognized as
equal, ensuring the self-ref fast path is used correctly instead of falling back
to the circular $ref branch.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6876c357-ce61-4400-a84e-9373190e43ec
⛔ Files ignored due to path filters (3)
tests/data/jsonschema/definitions_v2_namespace.jsonis excluded by!tests/data/**/*.jsonand included by nonetests/data/jsonschema/nested_defs_namespace_ref.jsonis excluded by!tests/data/**/*.jsonand included by nonetests/data/jsonschema/root_ref_self_with_keywords.jsonis excluded by!tests/data/**/*.jsonand included by none
📒 Files selected for processing (5)
src/datamodel_code_generator/parser/jsonschema.pytests/data/expected/main/jsonschema/definitions_v2_namespace.pytests/data/expected/main/jsonschema/nested_defs_namespace_ref.pytests/data/expected/main/jsonschema/root_ref_self_with_keywords.pytests/main/jsonschema/test_main_jsonschema.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3445 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 147 147
Lines 31381 31440 +59
Branches 3694 3707 +13
=========================================
+ Hits 31381 31440 +59
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
🎉 Released in 0.65.0 This PR is now available in the latest release. See the release notes for details. |
Summary by CodeRabbit
$ref: "#") to merge/retain root schema content correctly.definitions/$defs, including metadata deduplication for reliable$id/anchor processing.$defs/definitionsnamespaces and self-references.